# -*- coding: utf-8 -*-
"""
spark  相关计算
"""

from pyspark import SparkConf, SparkContext
import os

os.environ['PYSPARK_PYTHON'] = "F:/projects/PycharmProjects/myprojects/pythonProject/venv/Scripts/python.exe"

conf = SparkConf().setMaster("local[*]").setAppName("test_spark_app")

sc = SparkContext(conf=conf)

rdd = sc.parallelize([('男', 20), ('男', 30), ('女', 40), ('女', 50)])

rdd2 = rdd.reduceByKey(lambda a, b: a + b)

print(rdd2.collect())

sc.stop()
